package hamsterwrench.data.rpg;

import hamsterwrench.OHRRPGCE;
import hamsterwrench.OHRRPGCE.HeroSpells;

import java.util.ArrayList;

/**
 * The Hero is a player-controlled character in the OHRRPGCE. As such, it is probably the most
 * data-intensive object in the system.
 * @author Matthias H. Lamers
 */
public class Hero {

    private String name;
    
    //Appearance
    private short battleSprite;
    private short battlePalette; //-1 for default
    private short overSprite;
    private short overPalette; //-1 for default
    private short portraitPic;
    private short portraitPalette; //-1 for default
    private short maxNameLength; // 0 for default (16)
    private short[] attackAPos = new short[2]; // in pixels, [x,y]
    private short[] attackBPos = new short[2]; // in pixels, [x,y]
    
    
    //Stats
    private short[][] stats = new short[12][2];
    
    //Defaults
    private short startLv;
    private short startWeapon;
    
    //Spell Lists
    private ArrayList<SpellList> list = new ArrayList<SpellList>(4); // we will add these lists at construction
    
    //Prefs
    private boolean renameOnAdd;
    private boolean renameFromMenu;
    private boolean hideEmptySpellLists;
    
    //Tags
    private short haveHeroTag;
    private short aliveTag;
    private short leaderTag;
    private short inActivePartyTag;
    
    //Elementals
    private float[] elementalDmgMulti = new float[64];
    
    public Hero(){
    	
    }
    
    class SpellList{
    	private short[] attack = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
    	// move number, -1 is none
    	private short[] level = new short[24]; // (character level +1; if 0, move is learnt from an item}
    	private OHRRPGCE.HeroSpells type;
    	/*
    	 * 0 - MP based
    	 * 1 - FF1 Lv MP based
    	 * 2 - Random
    	 * 3 - Reserved
    	 */
    	private String name;
    	
    	public void rename(String n){
    		name = n;
    	}

    	public String getName(){
    		return name;
    	}
    	
    	public void changeType(HeroSpells i){
    			type = i;
    	}
    	
    	public HeroSpells getType(){
    		return type;
    	}
    	
    	public short AttackNo(int position){
    		return attack[position];
    	}
    	
    	public short Level(int position){
    		return level[position];
    	}
    	
    	public void WriteAttack(int pos, short a, short l){
    		attack[pos] = a;
    		level[pos] = l;
    	}
    }

    //minutae
    
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public short getBattleSprite() {
		return battleSprite;
	}

	public void setBattleSprite(short battleSprite) {
		this.battleSprite = battleSprite;
	}

	public short getBattlePalette() {
		return battlePalette;
	}

	public void setBattlePalette(short battlePalette) {
		this.battlePalette = battlePalette;
	}

	public short getOverSprite() {
		return overSprite;
	}

	public void setOverSprite(short overSprite) {
		this.overSprite = overSprite;
	}

	public short getOverPalette() {
		return overPalette;
	}

	public void setOverPalette(short overPalette) {
		this.overPalette = overPalette;
	}

	public short getPortraitPic() {
		return portraitPic;
	}

	public void setPortraitPic(short portraitPic) {
		this.portraitPic = portraitPic;
	}

	public short getPortraitPalette() {
		return portraitPalette;
	}

	public void setPortraitPalette(short portraitPalette) {
		this.portraitPalette = portraitPalette;
	}

	public short getMaxNameLength() {
		return maxNameLength;
	}

	public void setMaxNameLength(short maxNameLength) {
		this.maxNameLength = maxNameLength;
	}

	public short getStartLv() {
		return startLv;
	}

	public void setStartLv(short startLv) {
		this.startLv = startLv;
	}

	public short getStartWeapon() {
		return startWeapon;
	}

	public void setStartWeapon(short startWeapon) {
		this.startWeapon = startWeapon;
	}

	public boolean isRenameOnAdd() {
		return renameOnAdd;
	}

	public void setRenameOnAdd(boolean renameOnAdd) {
		this.renameOnAdd = renameOnAdd;
	}

	public boolean isRenameFromMenu() {
		return renameFromMenu;
	}

	public void setRenameFromMenu(boolean renameFromMenu) {
		this.renameFromMenu = renameFromMenu;
	}

	public boolean isHideEmptySpellLists() {
		return hideEmptySpellLists;
	}

	public void setHideEmptySpellLists(boolean hideEmptySpellLists) {
		this.hideEmptySpellLists = hideEmptySpellLists;
	}

	public short getHaveHeroTag() {
		return haveHeroTag;
	}

	public void setHaveHeroTag(short haveHeroTag) {
		this.haveHeroTag = haveHeroTag;
	}

	public short getAliveTag() {
		return aliveTag;
	}

	public void setAliveTag(short aliveTag) {
		this.aliveTag = aliveTag;
	}

	public short getLeaderTag() {
		return leaderTag;
	}

	public void setLeaderTag(short leaderTag) {
		this.leaderTag = leaderTag;
	}

	public short getInActivePartyTag() {
		return inActivePartyTag;
	}

	public void setInActivePartyTag(short inActivePartyTag) {
		this.inActivePartyTag = inActivePartyTag;
	}
    
	public void setPositionA(short x, short y){
		attackAPos[0] = x;
		attackAPos[1] = y;
	}
	
	public void setPositionB(short x, short y){
		attackBPos[0] = x;
		attackBPos[1] = y;
	}
	
	public float getElementalDmgMulti(byte pos){
		return elementalDmgMulti[pos];
	}
	
	public void setElementalDmgMulti(byte pos, float x){
		elementalDmgMulti[pos] = x;
	}
	
	public short getSpellNo(int list, int pos){
		return this.list.get(list).AttackNo(pos);
	}
	
	public short getSpellLevel(int list, int pos){
		return this.list.get(list).Level(pos);
	}
	
	public String getListName(int list){
		return this.list.get(list).getName();
	}
	
	public short getStat(int s, int l){
		return stats[s][l];
	}
	
	public void setStat(int s, int l, short x){
		stats[s][l] = x;
	}
}
